-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: upgrade yaml submodule #413
Conversation
WalkthroughWalkthroughThe recent update integrates a JSON schema grammar into the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Parser
participant Lexer
participant MemoryManager
participant ArrayManager
User->>Parser: Initialize parsing with JSON schema grammar
Parser->>Lexer: Parse input for null, boolean, integer, float
Lexer-->>Parser: Return token for scalar type
Parser->>MemoryManager: Allocate memory for parsed data
MemoryManager-->>Parser: Return memory reference
Parser->>ArrayManager: Manage dynamic arrays for parsed data
ArrayManager-->>Parser: Return array operations result
Parser-->>User: Return parsed schema structure
Recent review detailsConfiguration used: .coderabbit.yaml Files ignored due to path filters (6)
Files selected for processing (56)
Files not processed due to max files limit (7)
Files not summarized due to errors (2)
Files skipped from review due to trivial changes (20)
Additional context usedLearnings (1)
LanguageTool
Biome
Markdownlint
Additional comments not posted (113)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
24 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
Outside diff range, codebase verification and nitpick comments (12)
resources/language-metavariables/tree-sitter-yaml/bindings/go/binding_test.go (1)
10-14
: Improve error message in the test function.The error message can be more descriptive to help diagnose issues.
- t.Errorf("Error loading YAML grammar") + t.Errorf("Failed to load YAML grammar: language is nil")resources/language-metavariables/tree-sitter-yaml/schema/json/grammar.js (1)
3-3
: Incorrect TypeScript reference pathThe
/// <reference types="tree-sitter-cli/dsl" />
directive points to a non-existent package and type definition.
tree-sitter-cli
is not listed in thepackage.json
.dsl
type definition does not exist in thetree-sitter-cli
package.Please verify and correct the reference path or ensure that the necessary package and types are added.
Analysis chain
Ensure TypeScript reference path is correct.
The
/// <reference types="tree-sitter-cli/dsl" />
directive should point to the correct types.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the TypeScript reference path. # Test: Check if the TypeScript reference path is correct. if grep -q 'tree-sitter-cli/dsl' "resources/language-metavariables/tree-sitter-yaml/schema/json/grammar.js"; then echo "Reference path is correct." else echo "Reference path is incorrect." fiLength of output: 165
Script:
#!/bin/bash # Check if tree-sitter-cli is listed in dependencies or devDependencies if grep -q '"tree-sitter-cli"' package.json; then echo "tree-sitter-cli is listed in package.json." else echo "tree-sitter-cli is not listed in package.json." fi # Check if dsl is a valid type definition within the tree-sitter-cli package (assuming types are declared in node_modules) if [ -d "node_modules/tree-sitter-cli/dsl" ]; then echo "dsl type definition exists in tree-sitter-cli package." else echo "dsl type definition does not exist in tree-sitter-cli package." fiLength of output: 326
resources/language-metavariables/tree-sitter-yaml/README.md (1)
3-3
: Consider reducing the number of exclamation marks.Using many exclamation marks might seem excessive and detract from the professional tone of the documentation.
- [![CI][ci]](https://github.com/tree-sitter-grammars/tree-sitter-yaml/actions) + [![CI][ci]](https://github.com/tree-sitter-grammars/tree-sitter-yaml/actions)Tools
LanguageTool
[style] ~3-~3: Using many exclamation marks might seem excessive (in this case: 4 exclamation marks for a text that’s 367 characters long)
Context: ...tter-grammars/tree-sitter-yaml/actions) ![discord][discord] ![matrix][matrix] ![npm][npm] [![crates][crates]](https://crates.io/crat...(EN_EXCESSIVE_EXCLAMATION)
resources/language-metavariables/tree-sitter-yaml/src/schema.json.c (1)
1-2
: Include a blank line after the include directive.Adding a blank line after the
#include
directive improves readability.#include <stdlib.h> #define SCH_STT_FRZ -1resources/language-metavariables/tree-sitter-yaml/schema/update-schema.js (1)
Line range hint
59-75
: Fix the regular expression to avoid negated empty character class.The regular expression includes a negated empty character class, which matches anything.
- const content = input.slice(startIndex, endIndex).replace(/^\s*if \(eof\).+\n/mg, "").trimEnd(); + const content = input.slice(startIndex, endIndex).replace(/^\s*if \(eof\).+\n/mg, "").trimEnd().replace(/[^]/g, "");resources/language-metavariables/tree-sitter-yaml/src/schema.core.c (1)
Line range hint
13-199
: Complexity inadv_sch_stt
function.The function
adv_sch_stt
is quite complex due to numerous case statements. Consider breaking it down into smaller functions to improve readability and maintainability.static int8_t handle_state_0(int32_t cur_chr, ResultSchema *rlt_sch) { if (cur_chr == '.') {*rlt_sch = RS_STRING; return 6;} if (cur_chr == '0') {*rlt_sch = RS_INTEGER; return 37;} // other conditions... return -1; // default case } static int8_t adv_sch_stt(int8_t sch_stt, int32_t cur_chr, ResultSchema *rlt_sch) { switch (sch_stt) { case SCH_STT_FRZ: break; case 0: return handle_state_0(cur_chr, rlt_sch); case 1: // handle state 1... // other cases... default: *rlt_sch = RS_STRING; return SCH_STT_FRZ; } if (cur_chr != '\r' && cur_chr != '\n' && cur_chr != ' ' && cur_chr != 0) *rlt_sch = RS_STRING; return SCH_STT_FRZ; }resources/language-metavariables/tree-sitter-yaml/schema/json/src/parser.c (3)
7-16
: Ensure Consistency in Macro Definitions.The macro definitions for various constants like
LANGUAGE_VERSION
,STATE_COUNT
, etc., should be documented to provide context for their values.- #define LANGUAGE_VERSION 14 + // Version of the language grammar + #define LANGUAGE_VERSION 14
18-24
: Symbol Identifiers Enumeration.The enumeration
ts_symbol_identifiers
defines symbol identifiers for the parser. Ensure that these symbols are consistent with the grammar definitions and are well-documented.- enum ts_symbol_identifiers { + // Enumeration for symbol identifiers + enum ts_symbol_identifiers {
26-33
: Document Symbol Names Array.The
ts_symbol_names
array maps symbol identifiers to their string representations. Adding a comment to explain this mapping can improve readability.- static const char * const ts_symbol_names[] = { + // Mapping of symbol identifiers to their string representations + static const char * const ts_symbol_names[] = {CONTRIBUTING.md (2)
65-67
: Specify Language for Code Block.Fenced code blocks should have a language specified for proper syntax highlighting.
- ``` + ```bash node ./resources/edit_grammars.mjs yamlTools
Markdownlint
65-65: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
102-104
: Avoid Bare URLs.Use Markdown syntax to format URLs to avoid bare URLs and improve readability.
- LSP target languages list: https://github.com/getgrit/rewriter/pull/7734/files#diff-f9d4f097b08d33241c5c8d15a2fbde0e37086c265ce0eba8decac20d5cd989c6R23 - VS Code client list: https://github.com/getgrit/rewriter/blob/f992490394a4807789504f1cea6a04b934ad3b24/apps/poolish/src/lsp-client.ts - VS Code command palette triggers: https://github.com/getgrit/rewriter/pull/7734/files#diff-b38f1d6304993a250903310722206e6c89c58c52c2d1bd4b6fdd8f7218810570R103 + [LSP target languages list](https://github.com/getgrit/rewriter/pull/7734/files#diff-f9d4f097b08d33241c5c8d15a2fbde0e37086c265ce0eba8decac20d5cd989c6R23) + [VS Code client list](https://github.com/getgrit/rewriter/blob/f992490394a4807789504f1cea6a04b934ad3b24/apps/poolish/src/lsp-client.ts) + [VS Code command palette triggers](https://github.com/getgrit/rewriter/pull/7734/files#diff-b38f1d6304993a250903310722206e6c89c58c52c2d1bd4b6fdd8f7218810570R103)Tools
Markdownlint
102-102: null
Bare URL used(MD034, no-bare-urls)
103-103: null
Bare URL used(MD034, no-bare-urls)
104-104: null
Bare URL used(MD034, no-bare-urls)
resources/language-metavariables/tree-sitter-yaml/schema/core/src/tree_sitter/parser.h (1)
3-6
: Document C++ Compatibility Macros.Add comments to explain the purpose of the
extern "C"
block for C++ compatibility.- #ifdef __cplusplus + // Ensure C++ compatibility + #ifdef __cplusplus
`${METAVARIABLE_GRAMMARS_DIR}/${language}-metavariable-scanner.c`, | ||
`${tsLangDir}/src/scanner.c` | ||
); | ||
await buildSimpleLanguage(log, language); | ||
await copyMyBuild("c", language); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure proper handling of YAML language build steps.
The steps for copying the scanner file and building the language are correctly defined. Consider adding error handling for the file copy and build operations to improve robustness.
try {
await fs.copyFile(
`${METAVARIABLE_GRAMMARS_DIR}/${language}-metavariable-scanner.c`,
`${tsLangDir}/src/scanner.c`
);
await buildSimpleLanguage(log, language);
await copyMyBuild("c", language);
} catch (error) {
log(`Error handling YAML language build steps:`, error);
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`${METAVARIABLE_GRAMMARS_DIR}/${language}-metavariable-scanner.c`, | |
`${tsLangDir}/src/scanner.c` | |
); | |
await buildSimpleLanguage(log, language); | |
await copyMyBuild("c", language); | |
try { | |
await fs.copyFile( | |
`${METAVARIABLE_GRAMMARS_DIR}/${language}-metavariable-scanner.c`, | |
`${tsLangDir}/src/scanner.c` | |
); | |
await buildSimpleLanguage(log, language); | |
await copyMyBuild("c", language); | |
} catch (error) { | |
log(`Error handling YAML language build steps:`, error); | |
} |
let from = `${METAVARIABLE_GRAMMARS_DIR}/${lang}-metavariable-grammar.js`; | ||
let to = path.join( | ||
LANGUAGE_METAVARIABLES_DIR, | ||
`tree-sitter-${dest ?? lang}/grammar.js` | ||
); | ||
await fs.copyFile(from, to); | ||
console.log(`Copied ${from} to ${to}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure path definitions are correct and handle potential errors.
The paths for source and destination are defined correctly. However, it is good practice to handle potential errors during the file copy operation to improve robustness.
let from = `${METAVARIABLE_GRAMMARS_DIR}/${lang}-metavariable-grammar.js`;
let to = path.join(
LANGUAGE_METAVARIABLES_DIR,
`tree-sitter-${dest ?? lang}/grammar.js`
);
try {
await fs.copyFile(from, to);
console.log(`Copied ${from} to ${to}`);
} catch (error) {
console.error(`Failed to copy ${from} to ${to}:`, error);
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
let from = `${METAVARIABLE_GRAMMARS_DIR}/${lang}-metavariable-grammar.js`; | |
let to = path.join( | |
LANGUAGE_METAVARIABLES_DIR, | |
`tree-sitter-${dest ?? lang}/grammar.js` | |
); | |
await fs.copyFile(from, to); | |
console.log(`Copied ${from} to ${to}`); | |
let from = `${METAVARIABLE_GRAMMARS_DIR}/${lang}-metavariable-grammar.js`; | |
let to = path.join( | |
LANGUAGE_METAVARIABLES_DIR, | |
`tree-sitter-${dest ?? lang}/grammar.js` | |
); | |
try { | |
await fs.copyFile(from, to); | |
console.log(`Copied ${from} to ${to}`); | |
} catch (error) { | |
console.error(`Failed to copy ${from} to ${to}:`, error); | |
} |
|
||
namespace tree_sitter_yaml { | ||
#define SCH_STT_FRZ -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use const
for defining constants.
Defining SCH_STT_FRZ
as a constant improves readability and prevents accidental modifications.
- #define SCH_STT_FRZ -1
+ const int8_t SCH_STT_FRZ = -1;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
#define SCH_STT_FRZ -1 | |
const int8_t SCH_STT_FRZ = -1; |
typedef enum { | ||
RS_STR, | ||
RS_INT, | ||
RS_NUL, | ||
RS_BOL, | ||
RS_FLT, | ||
}; | ||
RS_NULL, | ||
RS_BOOL, | ||
RS_FLOAT, | ||
} ResultSchema; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum Naming Consistency.
The enum values RS_NULL
, RS_BOOL
, and RS_FLOAT
should be consistent with the existing naming convention. Consider renaming RS_STR
and RS_INT
to RS_STRING
and RS_INTEGER
for better readability and consistency.
- RS_STR,
- RS_INT,
+ RS_STRING,
+ RS_INTEGER,
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
typedef enum { | |
RS_STR, | |
RS_INT, | |
RS_NUL, | |
RS_BOL, | |
RS_FLT, | |
}; | |
RS_NULL, | |
RS_BOOL, | |
RS_FLOAT, | |
} ResultSchema; | |
typedef enum { | |
RS_STRING, | |
RS_INTEGER, | |
RS_NULL, | |
RS_BOOL, | |
RS_FLOAT, | |
} ResultSchema; |
type ChildNode = { | ||
multiple: boolean; | ||
required: boolean; | ||
types: BaseNode[]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define ChildNode as an interface.
Defining ChildNode
as an interface instead of a type may provide better flexibility and clarity.
- type ChildNode = {
+ interface ChildNode {
multiple: boolean;
required: boolean;
types: BaseNode[];
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
type ChildNode = { | |
multiple: boolean; | |
required: boolean; | |
types: BaseNode[]; | |
}; | |
interface ChildNode { | |
multiple: boolean; | |
required: boolean; | |
types: BaseNode[]; | |
} |
type NodeInfo = | ||
| (BaseNode & { | ||
subtypes: BaseNode[]; | ||
}) | ||
| (BaseNode & { | ||
fields: { [name: string]: ChildNode }; | ||
children: ChildNode[]; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define NodeInfo as an interface.
Defining NodeInfo
as an interface instead of a type may provide better flexibility and clarity.
- type NodeInfo =
+ interface NodeInfoBase extends BaseNode {
+ subtypes?: BaseNode[];
+ fields?: { [name: string]: ChildNode };
+ children?: ChildNode[];
+ }
+ type NodeInfo = NodeInfoBase;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
type NodeInfo = | |
| (BaseNode & { | |
subtypes: BaseNode[]; | |
}) | |
| (BaseNode & { | |
fields: { [name: string]: ChildNode }; | |
children: ChildNode[]; | |
}); | |
interface NodeInfoBase extends BaseNode { | |
subtypes?: BaseNode[]; | |
fields?: { [name: string]: ChildNode }; | |
children?: ChildNode[]; | |
} | |
type NodeInfo = NodeInfoBase; |
type BaseNode = { | ||
type: string; | ||
named: boolean; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define BaseNode as an interface.
Defining BaseNode
as an interface instead of a type may provide better flexibility and clarity.
- type BaseNode = {
+ interface BaseNode {
type: string;
named: boolean;
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
type BaseNode = { | |
type: string; | |
named: boolean; | |
}; | |
interface BaseNode { | |
type: string; | |
named: boolean; | |
} |
type Language = { | ||
name: string; | ||
language: unknown; | ||
nodeTypeInfo: NodeInfo[]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define Language as an interface.
Defining Language
as an interface instead of a type may provide better flexibility and clarity.
- type Language = {
+ interface Language {
name: string;
language: unknown;
nodeTypeInfo: NodeInfo[];
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
type Language = { | |
name: string; | |
language: unknown; | |
nodeTypeInfo: NodeInfo[]; | |
}; | |
interface Language { | |
name: string; | |
language: unknown; | |
nodeTypeInfo: NodeInfo[]; | |
} |
static bool ts_lex(TSLexer *lexer, TSStateId state) { | ||
START_LEXER(); | ||
eof = lexer->eof(lexer); | ||
switch (state) { | ||
case 0: | ||
if (eof) ADVANCE(13); | ||
if (lookahead == '-') ADVANCE(1); | ||
if (lookahead == '0') ADVANCE(16); | ||
if (lookahead == 'f') ADVANCE(2); | ||
if (lookahead == 'n') ADVANCE(10); | ||
if (lookahead == 't') ADVANCE(7); | ||
if (('1' <= lookahead && lookahead <= '9')) ADVANCE(17); | ||
END_STATE(); | ||
case 1: | ||
if (lookahead == '0') ADVANCE(16); | ||
if (('1' <= lookahead && lookahead <= '9')) ADVANCE(17); | ||
END_STATE(); | ||
case 2: | ||
if (lookahead == 'a') ADVANCE(4); | ||
END_STATE(); | ||
case 3: | ||
if (lookahead == 'e') ADVANCE(15); | ||
END_STATE(); | ||
case 4: | ||
if (lookahead == 'l') ADVANCE(8); | ||
END_STATE(); | ||
case 5: | ||
if (lookahead == 'l') ADVANCE(14); | ||
END_STATE(); | ||
case 6: | ||
if (lookahead == 'l') ADVANCE(5); | ||
END_STATE(); | ||
case 7: | ||
if (lookahead == 'r') ADVANCE(9); | ||
END_STATE(); | ||
case 8: | ||
if (lookahead == 's') ADVANCE(3); | ||
END_STATE(); | ||
case 9: | ||
if (lookahead == 'u') ADVANCE(3); | ||
END_STATE(); | ||
case 10: | ||
if (lookahead == 'u') ADVANCE(6); | ||
END_STATE(); | ||
case 11: | ||
if (lookahead == '+' || | ||
lookahead == '-') ADVANCE(12); | ||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(19); | ||
END_STATE(); | ||
case 12: | ||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(19); | ||
END_STATE(); | ||
case 13: | ||
ACCEPT_TOKEN(ts_builtin_sym_end); | ||
END_STATE(); | ||
case 14: | ||
ACCEPT_TOKEN(sym_null); | ||
END_STATE(); | ||
case 15: | ||
ACCEPT_TOKEN(sym_bool); | ||
END_STATE(); | ||
case 16: | ||
ACCEPT_TOKEN(sym_int); | ||
if (lookahead == '.') ADVANCE(18); | ||
if (lookahead == 'E' || | ||
lookahead == 'e') ADVANCE(11); | ||
END_STATE(); | ||
case 17: | ||
ACCEPT_TOKEN(sym_int); | ||
if (lookahead == '.') ADVANCE(18); | ||
if (lookahead == 'E' || | ||
lookahead == 'e') ADVANCE(11); | ||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(17); | ||
END_STATE(); | ||
case 18: | ||
ACCEPT_TOKEN(sym_float); | ||
if (lookahead == 'E' || | ||
lookahead == 'e') ADVANCE(11); | ||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(18); | ||
END_STATE(); | ||
case 19: | ||
ACCEPT_TOKEN(sym_float); | ||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(19); | ||
END_STATE(); | ||
default: | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lexing Function Complexity.
The ts_lex
function has multiple case statements to handle different lexing states. Consider breaking it down into smaller functions for each state to improve readability and maintainability.
static bool lex_state_0(TSLexer *lexer) {
if (eof) ADVANCE(13);
if (lookahead == '-') ADVANCE(1);
// other conditions...
return false; // default case
}
static bool ts_lex(TSLexer *lexer, TSStateId state) {
START_LEXER();
eof = lexer->eof(lexer);
switch (state) {
case 0:
return lex_state_0(lexer);
// other cases...
default:
return false;
}
}
Committable suggestion was skipped due to low confidence.
static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) { | ||
uint32_t index = 0; | ||
uint32_t size = len - index; | ||
while (size > 1) { | ||
uint32_t half_size = size / 2; | ||
uint32_t mid_index = index + half_size; | ||
TSCharacterRange *range = &ranges[mid_index]; | ||
if (lookahead >= range->start && lookahead <= range->end) { | ||
return true; | ||
} else if (lookahead > range->end) { | ||
index = mid_index; | ||
} | ||
size -= half_size; | ||
} | ||
TSCharacterRange *range = &ranges[index]; | ||
return (lookahead >= range->start && lookahead <= range->end); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve Readability of set_contains
Function.
The set_contains
function can be simplified for better readability and performance.
static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
for (uint32_t i = 0; i < len; i++) {
if (lookahead >= ranges[i].start && lookahead <= ranges[i].end) {
return true;
}
}
return false;
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) { | |
uint32_t index = 0; | |
uint32_t size = len - index; | |
while (size > 1) { | |
uint32_t half_size = size / 2; | |
uint32_t mid_index = index + half_size; | |
TSCharacterRange *range = &ranges[mid_index]; | |
if (lookahead >= range->start && lookahead <= range->end) { | |
return true; | |
} else if (lookahead > range->end) { | |
index = mid_index; | |
} | |
size -= half_size; | |
} | |
TSCharacterRange *range = &ranges[index]; | |
return (lookahead >= range->start && lookahead <= range->end); | |
} | |
static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) { | |
for (uint32_t i = 0; i < len; i++) { | |
if (lookahead >= ranges[i].start && lookahead <= ranges[i].end) { | |
return true; | |
} | |
} | |
return false; | |
} |
This should come after #412
Update the yaml submodule to 7b03feefd36b5f155465ca736c6304aca983b267 and sync our grammar/scanner.
Greptile Summary
This is an auto-generated summary
resources/edit_grammars.mjs
to sync YAML grammar/scannercrates/language/src/yaml.rs
test for YAML metavariableresources/language-metavariables/tree-sitter-yaml/.travis.yml
andCHANGELOG.md
resources/language-metavariables/tree-sitter-yaml/Makefile
andPackage.swift
resources/language-metavariables/tree-sitter-yaml/binding.gyp
andbinding.cc
for new build configurationsSummary by CodeRabbit
New Features
tree-sitter-yaml
module, enabling support for YAML parsing of null, boolean, integer, and float values.Improvements
Updates